package sso

import (
	"crypto/sha256"
	"fmt"

	servicesSystem "admin_template/bff/admin/internal/service/system"
	hertzMiddleware "gitee.com/byx_darwin/go-tools/hertz/middleware"
	"github.com/cloudwego/hertz/pkg/app/middlewares/server/recovery"
	"github.com/cloudwego/hertz/pkg/app/server"
)

func Register(server *server.Hertz, api *servicesSystem.SSOService) {
	apiGroup := server.Group(fmt.Sprintf("/%s/system/sso", api.Config.ServerOption.Registry.Version))
	apiGroup.Use(recovery.Recovery(recovery.WithRecoveryHandler(api.RecoveryHandler)))
	apiGroup.Use(hertzMiddleware.Auth(api, sha256.New))
	{
		apiGroup.POST("", api.Login)
		apiGroup.DELETE("", api.Logout)
	}
}
